import { Post, Get, Put, Delete } from '@/utils/request.ts'

export interface CreateDictDto {
  name: string
  type: string
  status: boolean
  sort: number
  remark?: string
  entries: Array<{ label: string; value: string }>
}

export interface dictListApiType {
  pageNo: number
  pageSize: number
}

export const createDictApi = (data: CreateDictDto) => {
  return Post<CreateDictDto, void>('/blog/dicts', data)
}

export const dictListApi = (data: dictListApiType) => {
  return Get<dictListApiType, void>('/blog/dicts', data)
}

export const dictOptionsApi = (type: string) => {
  return Get<never, CreateDictDto>('/blog/dicts/type/' + type)
}

export const updateDictApi = (id: string, data: {entries: CreateDictDto['entries'] }) => {
  return Put<{entries: CreateDictDto['entries'] }, void>('/blog/dicts/' + id, data)
}

export const deleteDictApi = (id: string) => {
  return Delete<never, void>('/blog/dicts/' + id)
}
